document.getElementById("password").classList.add("input-password");
document.getElementById("toggle-password").classList.remove("d-none");
const passwordInput = document.getElementById("password");
const togglePasswordButton = document.getElementById("toggle-password");
togglePasswordButton.addEventListener("click", togglePassword);
function togglePassword() {
    if (passwordInput.type === "password") {
        passwordInput.type = "text";
        togglePasswordButton.setAttribute("aria-label", "Hide password.");
    } else {
        passwordInput.type = "password";
        togglePasswordButton.setAttribute(
            "aria-label",
            "请输入密码 " +
            "Warning: this will display your password on the screen."
        );
    }
}

function login(){
    var data={
        "username":$("#username").val(),
        "password":$("#password").val()
    }

    $.ajax({
        url: '/login', /*接口域名地址*/
        type: 'post',
        data: data,
        success: function (res) {
            if(res.success){
                var token=res.data.token;
                window.location.href='/index?token='+token;

                localStorage.setItem("token",token);
            }else {
                window.location.href='/';
            }
        }
    })
}

